﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Примеры_MySQL
{
    class Program
    {

                //MySql.Data.MySqlClient.MySqlConnection conn;
                //MySql.Data.MySqlClient.MySqlCommand cmd;

                //conn = new MySql.Data.MySqlClient.MySqlConnection();
                //cmd = new MySql.Data.MySqlClient.MySqlCommand();
                //conn.ConnectionString = strConnection;
                //try
                //{
                //    conn.Open();
                //    cmd.Connection = conn;

                //    cmd.CommandText = "INSERT INTO myTable VALUES(NULL, @number, @text)";
                //    cmd.Prepare();
                //    cmd.Parameters.AddWithValue("@number", 1);
                //    cmd.Parameters.AddWithValue("@text", "One");
                //    for (int i=1; i <= 1000; i++)
                //    {
                //        cmd.Parameters["@number"].Value = i;
                //        cmd.Parameters["@text"].Value = "A string value";
                //        cmd.ExecuteNonQuery();
                //    }
                //}
                //catch (MySql.Data.MySqlClient.MySqlException ex)
                //{
                //    MessageBox.Show("Error " + ex.Number + " has occurred: " + ex.Message,
                //        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //}


        static void Main(string[] args)
        {
           // DataTable MyTable = new DataTable();
            MySql.Data.MySqlClient.MySqlConnection conn;
            MySql.Data.MySqlClient.MySqlCommand cmd;
            //MySql.Data.MySqlClient.MySqlDataAdapter myAdapter;

            conn = new MySql.Data.MySqlClient.MySqlConnection();
            cmd = new MySql.Data.MySqlClient.MySqlCommand();
            //myAdapter = new MySql.Data.MySqlClient.MySqlDataAdapter();

            conn.ConnectionString = "server=92.255.251.110;uid=ast;pwd=7hxSAYcrYCjn7nb5;database=pager;";
            //conn.ConnectionString = "server=localhost;uid=ast;pwd=7hxSAYcrYCjn7nb5;database=pager;";
            conn.Open();
            cmd.Connection = conn;
//cmd.Prepare();
           // cmd.CommandText = "DROP TABLE signal_temp_copy";

            cmd.CommandText = "TRUNCATE TABLE signal_temp_copy";
            string secCode2 = "BRV1";
            string date = DateTime.Now.ToString("yyyyMMdd");
            string time = DateTime.Now.ToString("HH0000");
            string short_long = "", price = "" , comment = "";
            

            cmd.CommandText = "INSERT INTO `signal_temp_copy` (`seccode`,`date`,`time`,`signal`,`short_long`,`forces`,`price`,`comments`,`type`,`time_frame`,`sent`) VALUES ('"

                                                + secCode2 + "','"
                                                + date + "','"
                                                + time + "',"
                                                + "'glass','"
                                                + short_long + "',"
                // + Convert.ToString(qoute.OrderDirection) + "',"
                                                + "'2','"
                                                + price + "','"
                                                + comment + "',"
                                                + "'glass',"
                                                + "'60',"
                                                + "'0'"
                               + ")";
            cmd.ExecuteNonQuery();
            
            //cmd.ExecuteNonQuery();
            conn.Close();

        }
    }
}
